#include "stdafx.h"
#include "codehelp.h"
#include "OptionDlg.h"
#include "NodeDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif


COptionDlg::COptionDlg(CWnd* pParent /*=NULL*/)
	: CDialog(COptionDlg::IDD, pParent)
{
	m_nLineMaxChar = 0;
	m_bShow = FALSE;
	m_bMultiIns = FALSE;
}


void COptionDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Text(pDX, IDC_EDIT1, m_nLineMaxChar);
	DDX_Check(pDX, IDC_CHECK1, m_bShow);
	DDX_Check(pDX, IDC_CHECK2, m_bMultiIns);
}


BEGIN_MESSAGE_MAP(COptionDlg, CDialog)
	ON_WM_PAINT()
END_MESSAGE_MAP()

#include "CHGlobal.h"
BOOL COptionDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();

	GetDlgItem(IDC_EDIT1)->SetFont(&CHGlobalData.font, FALSE);
	GetDlgItem(IDOK)->SetFont(&CHGlobalData.font, FALSE);
	GetDlgItem(IDCANCEL)->SetFont(&CHGlobalData.font, FALSE);

	m_nLineMaxChar = theOption.LineMaxChar();
	m_bMultiIns = theOption.MultiIns();
	m_bShow = theOption.ShowTabImage();
	UpdateData(FALSE);
	
	return TRUE;
}

void COptionDlg::OnOK() 
{
	UpdateData();
	if(m_nLineMaxChar < 40)
	{
		AfxMessageBox("if(m_nLineMaxChar < 40)");
		return;
	}
	theOption.LineMaxChar(m_nLineMaxChar);
	theOption.ShowTabImage(m_bShow);
	theOption.MultiIns(m_bMultiIns);

	CDialog::OnOK();
}

void COptionDlg::OnPaint() 
{
	CPaintDC dc(this);
	CNodeDlg::PaintHeader(this, &dc, "COptionDlg::OnPaint()", IDB_PAINT);
}
